<template>
    <div>
        <el-table :data="sourceData" style="width: 100%" class='pch-table' stripe>
            <el-table-column prop="id" width="100" label="ID"></el-table-column>
            <el-table-column prop="realName" label="姓名"></el-table-column>
             <el-table-column prop="avatar"  label="微信头像" width="150">
                <template slot-scope="scope">
                    <img class="avatar" :src="scope.row.avatar" alt="">
                </template>
            </el-table-column>
             <el-table-column prop="avatar"  label="简历图片" width="150">
                <template slot-scope="scope">
                    <img class="avatar" :src="scope.row.resumeImg.url" alt="">
                </template>
            </el-table-column>
            <el-table-column prop="gender"  label="性别"></el-table-column>
            <el-table-column prop="department"  label="院系"></el-table-column>
              <el-table-column prop="activeState"  label="激活状态">
                <template slot-scope="scope">
                    <span>{{!scope.row.activeState?'未激活':'已激活'}}</span>
                </template>
            </el-table-column>
            <el-table-column prop="school" label="所在学校" width="200"></el-table-column>
            <el-table-column prop="nickname" label="微信昵称" width="100"></el-table-column>
            <el-table-column prop="birthday" label="年龄"></el-table-column>
            <el-table-column prop="applyNum" label="申请面试的数量"></el-table-column>
            <el-table-column prop="inviteNum" label="收到面试的数量"></el-table-column>
            <el-table-column prop="activeTime"  label="激活时间" width="200">
                <template slot-scope="scope">
                    <span>{{renderDate(scope.row.activeTime)}}</span>
                </template>
            </el-table-column>
            <el-table-column prop="createTime"  label="注册时间" width="200">
                <template slot-scope="scope">
                    <span>{{renderDate(scope.row.createTime)}}</span>
                </template>
            </el-table-column>
        </el-table>

        <el-pagination
            @current-change="handleCurrentChange"
            :current-page.sync="params.pageNumber"
            :page-size="params.pageSize"
            background
            layout="prev, pager, next, jumper"
            :total="params.total">
        </el-pagination>

    </div>
</template>

<script>
    import api from '@/api'
    export default {
        data() {
            return {
                sourceData: [],
                params: {
                    pageNumber: 1,
                    pageSize: 10,
                    total: 1,
                    tid:0
                }
            }
        },
        created(){
            let {id} = this.$route.query;
            this.params.tid = id
            this.fetch()
        },
        methods: {
            look(row){
                this.$router.push('/teacher/detail?id='+row.id)
            },
            see(row){
                this.$router.push('/teacher/student/list?id='+row.id)
            },
            renderDate(uninx) {
                uninx*=1;
                return uninx.toDate()
            },
            handleCurrentChange(val) {
                this.params.pageNumber = val
                this.fetch()
            },
            fetch(){
                api.getTeacherStudentList(this.params).then((res) => {
                    if (res.code == 200 && res.data) {
                        let {data} = res;
                        this.sourceData = data
                        this.params.total = data.totalElements
                    }
                })
            },
        },
        components: {}
    }
</script>

<style lang="scss">
.el-table__row{
    .cell{
        img.avatar{
            max-width:100px;
            max-height: 100px;
        }
    }
}
</style>